<%@ page language="java" import="java.util.*,com.fescoservice.model.*" pageEncoding="UTF-8"%>
<%@page import="com.fescoservice.config.PropertiesConfig"%>

<%
	String langfilename = "/resources/message";
	Long countl =request.getAttribute("counts")==null?0:(Long) request.getAttribute("counts");
	String counts = Long.toString(countl);
	List customerlist =request.getAttribute("customerlist")==null?new ArrayList():(List<Company>) request.getAttribute("customerlist");
	String serchOptionSel =  request.getAttribute("SerchOptionSel")==null?"":(String)request.getAttribute("SerchOptionSel");
	String serchOptionValue =  request.getAttribute("SerchOptionValueSel")==null?"":(String)request.getAttribute("SerchOptionValueSel");
	int listSize=PropertiesConfig.getInstance().getInt("ListSize.Customer");
	int pageNumber =(Integer) request.getAttribute("pageNumber");
	int pageCount =(countl.intValue()/listSize)+((0==countl.intValue()%listSize)?0:1);
%>
<%@include file="../common/LocaleManager.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Fesco Service</title>
		<link rel="stylesheet" href="<%=path%>/js/jquery/themes/redmond/jquery.ui.all.css">
		<script src="<%=path%>/js/jquery/jquery-1.5.1.js"></script>
		<script src="<%=path%>/js/jquery/external/jquery.bgiframe-2.1.2.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.core.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.widget.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.mouse.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.button.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.draggable.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.position.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.resizable.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.dialog.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.effects.core.js"></script>
		<script src="<%=path%>/js/jquery/jquery.pager.js"></script>
		<link rel="stylesheet" href="<%=path%>/css/admin.css">
	
		<style type="text/css">
			
		</style>
		<script type="text/javascript">
			$(function() {
				function pageClick(pageclickednumber) { 
					document.forms.mainForm.action = '<%=path%>/action/Customer.htm?cmd=list';
					document.forms.mainForm.page.value=pageclickednumber;
					document.forms.mainForm.submit();		
					//$("#pager").pager({ pagenumber: pageclickednumber, pagecount: 15, buttonClickCallback: PageClick 
				}
				$("#btnAdd").button().click(function() {
					document.forms.mainForm.action = '<%=path%>/action/Customer.htm?cmd=addCustomerInit';
					document.forms.mainForm.submit();		
				});
				$("#btnSearch").button().click(function() {
					document.forms.mainForm.action = '<%=path%>/action/Customer.htm?cmd=list';
					document.forms.mainForm.submit();		
				});
				$("#pager").pager({ pagenumber: <%=pageNumber%>, pagecount: <%=pageCount%>, buttonClickCallback: pageClick }); 
				
			});
			
			
			function modify(custId){
				document.forms.mainForm.action = '<%=path%>/action/Customer.htm?cmd=modifyCustomerInit';		
				document.forms.mainForm.custId.value = custId;
				document.forms.mainForm.submit();
			}
			function viewContent(custId){
				document.forms.mainForm.action = '<%=path%>/action/Customer.htm?cmd=viewCustomer&Flag=oper';	
				document.forms.mainForm.custId.value = custId;
				document.forms.mainForm.submit();
			}
			
			function doDelete(custId){
				document.forms.mainForm.action = '<%=path%>/action/Customer.htm?cmd=deleteCustomer';	
				document.forms.mainForm.custId.value = custId;
				document.forms.mainForm.submit();
			}
			
			
		</script>
	</head>
	<body>
		
		<div class="wrapContent">		
			<form name="mainForm" method="post">
				<input type="hidden" name="page" value="" />
				<input type="hidden" name="custId" value="" />
			
			<div class="ui-widget categorylist">
				<div class="search">

					<%=resource.getString("FS_T_SEARCHBYTYPE")%>
					<select name="SerchOptionSel" id="SerchOptionSel" class=" ui-corner-all">
					
						<option value="2" <% if("2".equals(serchOptionSel)){%> selected="selected"	<% }%>><%=resource.getString("FS_T_CUST_NAME_EN")%></option>
						<option value="1" <% if("1".equals(serchOptionSel)){%> selected="selected"	<% }%>><%=resource.getString("FS_T_CUST_PASS_ID")%></option>
						<option value="3" <% if("3".equals(serchOptionSel)){%> selected="selected"	<% }%>><%=resource.getString("FS_T_CUST_COMPANY_NAME")%></option>

					</select>
					<input type="text" name="SerchOptionValueSel" class=" ui-corner-all"  value="<%=serchOptionValue %>" maxlength="80" />
					
					<div id="btnSearch" ><%=resource.getString("FS_T_SEARCH")%></div>
				</div>
				<h1>
					 <%=resource.getString("FS_T_TOTALCOUNT")%> :  <%=counts %> 
				</h1>
				<table class="ui-widget ui-widget-content">
						<tr class="ui-widget-header ">
							<th nowrap >
								<%=resource.getString("FS_T_CUST_NAME_EN")%>
								<div id="create-menu2"></div>
							</th>
							<th nowrap >
								<%=resource.getString("FS_T_CUST_PASS_ID")%>
								<div id="create-menu1"></div>
							</th>
							
							<th nowrap >
								<%=resource.getString("FS_T_CUST_NAME_CN")%>
								<div id="create-menu3"></div>
							</th>		
							<th nowrap >
								<%=resource.getString("FS_T_CUST_PASS_VALID_DATE")%>
								<div id="create-menu3"></div>
							</th>	
							<th nowrap >
								<%=resource.getString("FS_T_CUST_COMPANY_NAME")%>
								<div id="create-menu3"></div>
							</th>	
							<th nowrap >
								<%=resource.getString("FS_T_OPERATION_COL")%>
								<div id="create-menu3"></div>
							</th>							
						</tr>
					</thead>
					<tbody>
					<% if(customerlist.size()>0) { 
						Customer customer = null;
						for(int i=0;i<customerlist.size();i++){
						customer = (Customer)customerlist.get(i);
					%>
					
						<tr class="operTR<%=i%2 %>" >
							<td nowrap >
								<%=customer.getCustFirstnameEn()+" "+customer.getCustLastnameEn() %>
							</td>
							<td nowrap >
								<%=customer.getPassId() %>
							</td>
							
							<td nowrap >
								<%=customer.getCustNameCn() %>
							</td>
							<td nowrap >
								<%=customer.getPassValidDate() %>
							</td>
							<td nowrap >
								<%=customer.getCompanyName() %>
							</td>
							<td nowrap  class="operation">
								<div nowrap><a href="javascript:modify('<%=customer.getCustId() %>');" ><%=resource.getString("FS_T_MODIFY")%></a></div>

								<div nowrap><a href="javascript:viewContent('<%=customer.getCustId()%>');" ><%=resource.getString("FS_T_VIEWCONTENT")%></a></div>
							</td>
						</tr>
					<%	}
					}else{ %>

						<tr>
							<td nowrap  colspan="6">
								<%=resource.getString("FS_M_NORESULT")%>
							</td>
						</tr>
					<%} %>
					</tbody>
				</table>
				<div class="bottom">
					<div id="pager"></div>
				</div>
				<div class="buttonGroupRight">
			   		<div id="btnAdd" ><%=resource.getString("FS_T_ADD")%></div>
					
				</div>	
			</div>
			</form>
		</div>
		<script type="text/javascript"	>	
		//import scripts below to pages which display in right frame, for ajust the scroll height
		parent.scroll(0,0);
		parent.setFrameHeight(document.body.scrollHeight+200);
		</script>
	</body>
</html>